package testshuju;


/**
 * Created by Administrator on 2016/6/14.
 */
public class RecordEntity {
    public enum RECORD_TYPE {
        CONTACT(1),URL(2),TEXT(3);
        private int typeValue;
        private String typeName;
        private RECORD_TYPE(int typeValue){
            this.typeValue = typeValue;
            switch (typeValue){
                case 1:
                    this.typeName = "联系人";
                    break;
                case 2:
                    this.typeName = "网址";
                    break;
                case 3:
                    this.typeName = "文本";
                    break;
            }
        }

        public static  RECORD_TYPE parseFromValue(int typeValue){
            switch (typeValue){
                case 1:
                    return CONTACT;
                case 2:
                    return URL;
                case 3:
                    return TEXT;
                default:
                    return TEXT;
            }
        }

        public int getTypeValue() {
            return typeValue;
        }

        public String getTypeName() {
            return typeName;
        }
    };
    public enum RECORD_FROM {
        MAKE(0),SCAN(1);
        private int value;
        private RECORD_FROM(int value){
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public static RECORD_FROM parseFromValue(int value){
            if(value == 0) return MAKE;
            else return SCAN;
        }
    }

    public RecordEntity(){}

    public RecordEntity(RECORD_TYPE recordType, Object recordContent, RECORD_FROM recordFrome, long recordTime) {
        this.recordType = recordType;
        this.recordContent = recordContent;
        this.recordFrome = recordFrome;
        this.recordTime = recordTime;
    }

    public RecordEntity(RECORD_TYPE recordType, Object recordContent, RECORD_FROM recordFrome) {
        this.recordType = recordType;
        this.recordContent = recordContent;
        this.recordFrome = recordFrome;
        this.recordTime = System.currentTimeMillis();
    }

    private int id;
    private RECORD_TYPE recordType;
    private Object recordContent;
    private RECORD_FROM recordFrome;
    private long recordTime;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public RECORD_TYPE getRecordType() {
        return recordType;
    }

    public void setRecordType(RECORD_TYPE recordType) {
        this.recordType = recordType;
    }

    public Object getRecordContent() {
        return recordContent;
    }

    public void setRecordContent(Object recordContent) {
        this.recordContent = recordContent;
    }

    public RECORD_FROM getRecordFrome() {
        return recordFrome;
    }

    public void setRecordFrome(RECORD_FROM recordFrome) {
        this.recordFrome = recordFrome;
    }

    public long getRecordTime() {
        return recordTime;
    }

    public void setRecordTime(long recordTime) {
        this.recordTime = recordTime;
    }

    @Override
    public String toString() {
        String contentStr;
        if(recordType == RECORD_TYPE.CONTACT){
            contentStr = ContactEntity.toVCardFormat((ContactEntity)recordContent);
        } else {
            contentStr = (String) recordContent;
        }

        return "RecordEntity{" +
                "id=" + id +
                ", recordType=" + recordType +
                ", recordContent=" + contentStr +
                ", recordFrome=" + recordFrome +
                ", recordTime=" + recordTime +
                '}';
    }
}
